<?php
elgg_register_event_handler('init', 'system', 'game_init');
elgg_register_page_handler('game', 'game_page_handler');

function game_init() {
    elgg_extend_view('css/elgg', 'game/css');
//    elgg_extend_view('js/elgg','game/js');

    $js_url = 'mod/game/vendors/game/jquery-1.6.1.js';
    elgg_register_js('jquery1.6', $js_url);
    $js2_url = 'mod/game/vendors/game/basic.js';
    elgg_register_js('basic', $js2_url);
    $js3_url = 'mod/game/vendors/game/jquery.simplemodal.js';
    elgg_register_js('jquery.simplemodal', $js3_url);
    $js4_url = 'mod/game/vendors/game/jquery.js';
    elgg_register_js('jquery', $js4_url);    

    $item = new ElggMenuItem('Social Game',elgg_echo('Social Game') , 'game/newGame');
    elgg_register_menu_item('site', $item);
}

function game_page_handler($segments) {
    elgg_load_js('jquery1.6');
    elgg_load_js('basic');
    elgg_load_js('jquery.simplemodal');
    elgg_load_js('jquery');
      
    switch ($segments[0]) {
        default :
        case 'newGame' :
           include elgg_get_plugins_path() . 'game/pages/game/newGame.php';
           break;

       case 'save_thewire' :
           include elgg_get_plugins_path() . 'game/ajaxs/save_thewire.php';
           break;
    }

    return true;
}